package com.eshop.modules.shop.service.mapper;

import org.apache.ibatis.annotations.Select;
import com.eshop.modules.product.vo.SystemStoreQueryVo;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Repository;
import com.eshop.modules.shop.domain.SystemStore;
import com.eshop.common.mapper.CoreMapper;

@Repository
public interface SystemStoreMapper extends CoreMapper<SystemStore>
{
    @Select({ "SELECT*,ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN((#{lat} * PI() / 180 - latitude * PI() / 180    ) / 2),2) + COS(40.0497810000 * PI() / 180) * COS(latitude * PI() / 180) * POW(    SIN((#{lon} * PI() / 180 - longitude * PI() / 180) / 2),2))) * 1000) AS distance    FROM system_store WHERE is_del=0 AND is_show = 1 ORDER BY distance ASC" })
    List<SystemStoreQueryVo> getStoreList(final Page page, @Param("lon") final double lon, @Param("lat") final double lat);
}
